package com.rabbitmq.learn.Simple;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.learn.common.ConnectionUtils;
import com.rabbitmq.learn.common.RabbitMqConstant;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * Created by Lxk on 2019/8/11.
 */
public class Sender {

    public static void main(String[] args) throws IOException, TimeoutException {
        //获取连接
        Connection con = ConnectionUtils.getConnection();
        //获取通道
        Channel channel = con.createChannel();
        //创建队列声明
        channel.queueDeclare(RabbitMqConstant.Simple.QUEUE_NAME,false,false,false,null);

        String msg = "test simple,你好哈";

        channel.basicPublish("",RabbitMqConstant.Simple.QUEUE_NAME,null,msg.getBytes());

        System.out.println("send finish!!");

        channel.close();

        con.close();
    }

}
